﻿<UserControl x:Class="DictationToolSilverlight.View.MediaPlayerView"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">

    <Grid MinWidth="600" MinHeight="80">
        <Grid.RowDefinitions>
            <RowDefinition Height="*"/>
            <RowDefinition Height="Auto"/>
        </Grid.RowDefinitions>
        <Border Grid.RowSpan="2" BorderBrush="#FF00AAEE" BorderThickness="0,2" Margin="0" CornerRadius="0" Background="White"/>

        <Grid x:Name="mediaPlayerRoot" Grid.Row="0" Margin="5">
            <Grid.RowDefinitions>
                <RowDefinition Height="*"/>
                <RowDefinition Height="Auto"/>
            </Grid.RowDefinitions>
            <ContentControl x:Name="mediaElement" Grid.Row="0" Content="{Binding Path=MediaElement}" MinHeight="5" MaxHeight="300"/>
            <!--<MediaElement x:Name="mediaElement" Grid.Row="0"/>-->
            <Grid x:Name="seekTo" Grid.Row="1" Background="Transparent">
                <Border Height="8" BorderBrush="#FFDDDDDD" BorderThickness="1"/>
                <Rectangle x:Name="buffer" Height="8" HorizontalAlignment="Left" Fill="#FFDDDDDD" Width="{Binding Path=Buffer}"/>
                <Rectangle x:Name="process" Height="8" HorizontalAlignment="Left" Fill="#FF00AAEE" Width="{Binding Path=Process}"/>
                <Rectangle Height="14" HorizontalAlignment="Left" Fill="Orange" Width="2" Margin="-1,0,0,0">
                    <Rectangle.RenderTransform>
                        <TranslateTransform X="{Binding Path=StartPosition}" />
                    </Rectangle.RenderTransform>
                </Rectangle>
                <Rectangle Height="14" HorizontalAlignment="Left" Fill="Orange" Width="2" Margin="-1,0,0,0" Opacity="{Binding Path=Repeating, Converter={StaticResource BoolToVisible}}">
                    <Rectangle.RenderTransform>
                        <TranslateTransform X="{Binding Path=EndPosition}" />
                    </Rectangle.RenderTransform>
                </Rectangle>
            </Grid>
        </Grid>

        <Grid Grid.Row="1" Margin="0,5">
            <Grid.RowDefinitions>
                <RowDefinition Height="Auto"/>
                <RowDefinition Height="Auto"/>
            </Grid.RowDefinitions>
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="Auto"/>
                <ColumnDefinition Width="*"/>
                <ColumnDefinition Width="Auto"/>
                <ColumnDefinition Width="Auto"/>
            </Grid.ColumnDefinitions>

            <Grid Grid.Column="0" Grid.RowSpan="2">
                <StackPanel Orientation="Horizontal" HorizontalAlignment="Left" VerticalAlignment="Center">
                    <ToggleButton Width="30" Height="30" Margin="5,0" Style="{StaticResource PlayPause}" Command="{Binding Path=PlayPauseCommand}" IsChecked="{Binding Path=IsPlaying, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"/>
                    <Button Width="30" Height="30" Margin="5,0" Command="{Binding StopCommand}">
                        <Button.Content>
                            <Rectangle x:Name="content" Width="15" Height="15" RadiusX="1" RadiusY="1" Fill="White"/>
                        </Button.Content>
                    </Button>
                    <Button Width="30" Height="30" Margin="5,0" Click="Button_Click">
                        <Button.Content>
                            <Path x:Name="folder" Stretch="Uniform" Height="15" Fill="White"
                                  Data="F1 M 1,2.00002L 3.00003,2.00002L 3.00003,1.00002C 3.00003,0.447739 3.44774,1.52588e-005 4.00003,1.52588e-005L 11,1.52588e-005C 11.5523,1.52588e-005 12,0.447739 12,1.00002L 12,3.00002L 12,7.00002L 12,8.50008C 12,9.05235 11.5523,9.50008 11,9.50008L 1,9.50008C 0.447723,9.50008 0,9.05235 0,8.50008L 0,3.00002C 0,2.44774 0.447723,2.00002 1,2.00002 Z M 5.50005,2.33339C 4.94775,2.33339 4.50003,2.78111 4.50003,3.33339C 4.50003,3.88567 4.94775,4.33339 5.50005,4.33339L 9.50003,4.33339C 10.0523,4.33339 10.5,3.88567 10.5,3.33339C 10.5,2.78111 10.0523,2.33339 9.50003,2.33339L 5.50005,2.33339 Z "/>
                        </Button.Content>
                    </Button>
                </StackPanel>
            </Grid>
            <Grid Grid.Column="1" Grid.RowSpan="2">
                <Border CornerRadius="13" BorderBrush="LightGray" Background="White" Width="130" Height="25" HorizontalAlignment="Center" VerticalAlignment="Center" BorderThickness="1">
                    <Border.Effect>
                        <DropShadowEffect Opacity="0.317" BlurRadius="5" ShadowDepth="2" />
                    </Border.Effect>
                </Border>
                <StackPanel Orientation="Horizontal" HorizontalAlignment="Center" VerticalAlignment="Center" Background="Transparent">
                    <TextBlock Foreground="#FF00AAEE" FontWeight="Bold" Text="{Binding Path=MediaElement.Position, Converter={StaticResource TimeSpanToString}}"/>
                    <TextBlock Text=" / " Foreground="#FF00AAEE" FontWeight="Bold"/>
                    <TextBlock Foreground="#FF00AAEE" FontWeight="Bold" Text="{Binding Path=TotalTime, Converter={StaticResource TimeSpanToString} }"/>
                </StackPanel>
            </Grid>

            <Grid Grid.Column="2">
                <StackPanel Orientation="Horizontal" HorizontalAlignment="Center" VerticalAlignment="Center">
                    <Button Content="S" Width="20" Height="20" Margin="5,0" ToolTipService.ToolTip="Set Start Position" Command="{Binding Path=StartCommand}"/>
                    <Button Content="R" Width="20" Height="20" Margin="5,0" ToolTipService.ToolTip="Repeat" Command="{Binding Path=RepeatCommand}"/>
                    <Button Content="C" Width="20" Height="20" Margin="5,0" ToolTipService.ToolTip="Continue" Command="{Binding Path=ContinueCommand}"/>
                </StackPanel>
            </Grid>

            <Grid Grid.Column="3">
                <StackPanel Orientation="Horizontal">
                    <ToggleButton x:Name="speaker" Style="{StaticResource Speaker}" IsChecked="{Binding Path=Muted, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"/>
                    <Slider Width="50" Maximum="1" Value="{Binding Path=MediaElement.Volume, Mode=TwoWay}" IsEnabled="{Binding Path=IsChecked, ElementName=speaker}"/>
                </StackPanel>
            </Grid>

            <Grid Grid.Column="2" Grid.ColumnSpan="2" Grid.Row="2" Margin="5,3,5,0">
                <TextBlock Text="F7 : Pause / Play     F8 : Repeat" Foreground="#FF00AAEE"/>
            </Grid>
        </Grid>
    </Grid>
</UserControl>
